﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    Inherits="Admin_UserManagement" CodeBehind="UserManagement.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajt" %>
<%@ MasterType VirtualPath="~/Admin/Admin.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphTitle" runat="Server">
    Users
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="Server">
    <asp:ScriptManager ID="scriptManager1" runat="server" />
    <asp:LinkButton ID="lbUserCreation" Text="Create a user" runat="server" OnClick="btnNewUser_Click" />
    <br />
    <br />
    <asp:GridView ID="grvUsers" runat="server" AutoGenerateColumns="false" OnRowDeleting="DeleteRecord"
        DataKeyNames="ID" OnRowDataBound="RowDataBound">
        <Columns>
            <asp:TemplateField HeaderText="Linked to">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Constituent.Name") %>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Username">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "MembershipUser.UserName")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Email">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "MembershipUser.Email")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Creation date">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "MembershipUser.CreationDate")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Is online">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "MembershipUser.IsOnline")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Last login date">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "MembershipUser.LastLoginDate")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("ID") %>'
                        CommandName="Delete" Text="Delete" ForeColor="Black" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <ajt:ModalPopupExtender ID="modalNewUser" runat="server" TargetControlID="lbUserCreation"
        PopupControlID="pnlNewUser" PopupDragHandleControlID="PopupHeader" Drag="true"
        BehaviorID="ShowModal" BackgroundCssClass="modalBackground">
    </ajt:ModalPopupExtender>
    <asp:Panel ID="pnlNewUser" runat="server">
        <div id="modal">
            <div class="modal">
                <table width="300" border="0">
                    <tr>
                        <td valign="top" colspan="2">
                            <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser"
                                LoginCreatedUser="False">
                                <WizardSteps>
                                    <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                                        <ContentTemplate>
                                            <table>
                                                <tr>
                                                    <td align="center" colspan="2">
                                                        <p>
                                                            Create a user</p>
                                                        <br />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" class="style1">
                                                        <asp:Label ID="lblFirstName" runat="server" AssociatedControlID="txtFirstName">First Name:</asp:Label>
                                                    </td>
                                                    <td class="style1">
                                                        <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName"
                                                            ErrorMessage="First Name is required." ToolTip="First Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <asp:Label ID="lblLastName" runat="server" AssociatedControlID="txtLastName">Last Name:</asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtLastName"
                                                            ErrorMessage="Last Name is required." ToolTip="Last Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                                            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword"
                                                            ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                                            ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
                                                            ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="center" colspan="2">
                                                        <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                            ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                                            ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="center" colspan="2" style="color: Red;">
                                                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <br />
                                                    </td>
                                                </tr>
                                            </table>
                                        </ContentTemplate>
                                        <CustomNavigationTemplate>
                                            <table border="0" cellspacing="5" style="width: 100%; height: 100%;">
                                                <tr align="right">
                                                    <td>
                                                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                                                    </td>
                                                    <td>
                                                        <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Create User"
                                                            ValidationGroup="CreateUserWizard1" OnClientClick="showModal();" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </CustomNavigationTemplate>
                                    </asp:CreateUserWizardStep>
                                    <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                                    </asp:CompleteWizardStep>
                                </WizardSteps>
                            </asp:CreateUserWizard>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </asp:Panel>
</asp:Content>
